from exts import db

class Op(db.Model):
    __tablename__ = 'op'

    opId = db.Column(db.String(40), primary_key=True)
    userId = db.Column(db.ForeignKey('user.userId'), nullable=False, index=True)
    originImageId = db.Column(db.ForeignKey('originimage.imageId'), nullable=False, index=True)
    afterOpImageId = db.Column(db.ForeignKey('afteropimage.id'), nullable=False, index=True)

    afteropimage = db.relationship('Afteropimage', primaryjoin='Op.afterOpImageId == Afteropimage.id', backref='ops')
    originimage = db.relationship('Originimage', primaryjoin='Op.originImageId == Originimage.imageId', backref='ops')
    user = db.relationship('User', primaryjoin='Op.userId == User.userId', backref='ops')